<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends CommonController {
    public function index(){
        $this->info();
    }
    public function info(){
        $count['users'] = M('user')->where('1=1')->count();
        $count['infos'] = M('info')->where('1=1')->count();
        $count['infos'] = M('info')->where('1=1')->count();
        $count['bugs'] = M('bug')->where('1=1')->count();
        $this->assign('mark','index');
        $this->assign('umark','info');
        $this->assign('count',$count);
        $this->assign('sys_info',$this->get_sys_info());
        $this->display('info');
    }
    //删除缓存
    public function removeRuntime()
    {
        deldir(TEMP_PATH);
    }
    //获取系统信息
    public function get_sys_info(){
    		$sys_info['os']             = PHP_OS;
    		$sys_info['zlib']           = function_exists('gzclose') ? 'YES' : 'NO';//zlib
    		$sys_info['safe_mode']      = (boolean) ini_get('safe_mode') ? 'YES' : 'NO';//safe_mode = Off
    		$sys_info['timezone']       = function_exists("date_default_timezone_get") ? date_default_timezone_get() : "no_timezone";
    		$sys_info['curl']			= function_exists('curl_init') ? 'YES' : 'NO';
    		$sys_info['web_server']     = $_SERVER['SERVER_SOFTWARE'];
    		$sys_info['phpv']           = phpversion();
    		$sys_info['ip'] 			= GetHostByName($_SERVER['SERVER_NAME']);
    		$sys_info['fileupload']     = @ini_get('file_uploads') ? ini_get('upload_max_filesize') :'unknown';
    		$sys_info['max_ex_time'] 	= @ini_get("max_execution_time").'s'; //脚本最大执行时间
    		$sys_info['set_time_limit'] = function_exists("set_time_limit") ? true : false;
    		$sys_info['domain'] 		= $_SERVER['HTTP_HOST'];
    		$sys_info['memory_limit']   = ini_get('memory_limit');
            $sys_info['version']   	    = file_get_contents('./Application/Admin/Conf/version.txt');
    		$mysqlinfo = M()->query("SELECT VERSION() as version");
    		$sys_info['mysql_version']  = '';
    		if(function_exists("gd_info")){
      			$gd = gd_info();
      			$sys_info['gdinfo'] 	= $gd['GD Version'];
    		}else {
      			$sys_info['gdinfo'] 	= "未知";
    		}
    		return $sys_info;
    }
}
